package com.wish.g01.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wish.g01.base.dto.ContractDto;
import com.wish.g01.base.entity.CfContract;
import com.wish.g01.base.mapper.CfContractMapper;
import com.wish.g01.base.service.ICfContractService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 13536
 *
 * @since 2022-05-24
 */
@Service
public class CfContractServiceImpl extends ServiceImpl<CfContractMapper, CfContract> implements ICfContractService {

    /**
     * 合同的小区名称,租客姓名模糊查询
     * @param contractDto
     * @return
     */
    @Override
    public List<CfContract> getList(ContractDto contractDto) {

        QueryWrapper<CfContract> cfContractQueryWrapper = new QueryWrapper<>();

        if(StringUtils.isNotEmpty(contractDto.getPremiseName())){
            cfContractQueryWrapper.like("premise_name",contractDto.getPremiseName());
        }
        if(StringUtils.isNotEmpty(contractDto.getTenantName())){
            cfContractQueryWrapper.like("tenant_name",contractDto.getTenantName());
        }
        //逻辑删除 否
        cfContractQueryWrapper.eq("del_flg",0);
        //房租分期 否
        cfContractQueryWrapper.eq("rent_installment_flg",0);
        //租约保理 否
        cfContractQueryWrapper.eq("zybl_flg",0);
        //合同状态 已提交
        cfContractQueryWrapper.eq("contract_state",2);
        //续约状态 未续约
        cfContractQueryWrapper.eq("xuyue_state",0);
        //冻结状态 未冻结
        cfContractQueryWrapper.eq("freeze_status",0);

        List<CfContract> cfContracts = getBaseMapper().selectList(cfContractQueryWrapper);
        return cfContracts;
    }
}
